<?php
namespace app\web\controller;
use app\common\controller\StoreBaseController;
use think\Db;
/**
 * 店铺职位
 */
class ZhiweiController extends StoreBaseController
{
    public function index( $page = 1){
		$where['agent_id']= session('storeInfo')['id'];
		$list = db("line_zhiwei")->where($where)->select();
		return $this->fetch('index', ['list' => $list]);
	}
	/**
	 * 新增职位
	 */
	public function add(){
		$data['agent_id']=session('storeInfo')['id'];
		$data['name']=input("name");
		$res=db('line_zhiwei')->insert($data);
		if($res){
			return json(['code'=>200,'msg'=>"保存成功"]);
		}else{
			return json(['code'=>408,'msg'=>"保存失败"]);
		}
	}
	 /**
     * [del删除]
     * @author [longx] 
     */
    public function delete()
    {
        $id = input('param.id');
        if ($this->model->destroy($id)) {
            $this->success('删除成功');
        } else {
            $this->error('删除失败');
        }
    }
    /**
     * [edit 编辑]
     * @return [type] [description]
     * @author []
     */
    public function edit()
    {
    	$data['agent_id']=session('storeInfo')['id'];
		$data['name']=input('name');
		$data['id']=input('id');
		$res=db('line_zhiwei')->update($data);
		if($res){
			return json(['code'=>200,'msg'=>"修改成功"]);
		}else{
			return json(['code'=>408,'msg'=>"修改失败"]);
		}
          	
    }
}